package com.pactera.jep.service.sys.web.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.pactera.jep.service.sys.service.SyncService;

/**
 * 同步ESB数据controller，测试用，后续将会删除
 * @author ghost
 *
 */
@RestController
public class SyncController {

	private final static Logger logger = LoggerFactory.getLogger(SyncController.class);

	@Autowired
	private SyncService syncService;

	@RequestMapping(value = "/sync", method = RequestMethod.GET)
	public void sync(HttpServletResponse response) {
		try {
			response.getWriter().write("OK");
			syncService.doSync();
		} catch (IOException e) {
			logger.error("同步数据过程出现异常：{}", e.getMessage());
		}

	}
}
